import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart' as getPack;
// import 'package:share_plus/share_plus.dart';

import '../../routes/app_pages.dart';

class RtCallController extends GetxController {
  var srcLang = "zh-CN";
  var tgtLang = "en-US";
  var rtCallType = "video".obs;
  var fromLanFlagDisplay = '中文（普通话，中国大陆）'.obs;
  var toLanFlagDisplay = '英语（美国）'.obs;

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  void changeCallType(String? value) {
    if (value != null) {
      rtCallType.value = value;
    }
  }

  Future<void> handleInvite() async {
    Get.toNamed(Routes.REALTIME_CALL, parameters: {
      'srcLang': fromLanFlagDisplay.value,
      'tgtLang':toLanFlagDisplay.value,
      'callType': rtCallType.value,
      'srcCode':srcLang,
      'tgtCode':tgtLang
    });
  }

  void chooseFromLanguages() async {
    final languageItem = await getPack.Get.toNamed(Routes.LANGUAGE_OPINION,arguments: {'filter':true});
    srcLang= languageItem['code'];
    fromLanFlagDisplay.value = languageItem['desc'];
  }

  void chooseToLanguages() async {
    final languageItem = await getPack.Get.toNamed(Routes.LANGUAGE_OPINION,arguments: {'filter':true});
    tgtLang = languageItem['code'];
    toLanFlagDisplay.value = languageItem['desc'];
  }

}
